<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="./jquery-2.1.1/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="./LoginAction">
<input type="text" name="name" value=""><input id="btnVail" type="button" value="检验"><br>
<input type="text" name="pwd" value=""><br>
<input type="submit" value="确定">
<div id="show"></div>
</form>
<script type="text/javascript">
$(function(){
 $("#btnVail").click(function(){
 var name=$("input[name='name']").val();
        $.ajax({
                 type: "GET",//1.type:get/post
                 url: "./VaildateAction?user="+name,//2.url.要跳转的action
                 dataType: "text",
                 success: function(data){//success：成功后->callback        
                 //        动作标签:function(参数列表){} ->onClick:function(参数列表){}
                 console.log("success");
                     if(data=="true"){
                        $("#show").html("=====ok====="+"<br/>"+"name="+$("[name=name]").val()+"<br/>"+"pwd="+$("[name=pwd]").val());
                     }else if(data=="false"){
                        $("#show").html("==信息不符合==");
                    }
                 },
                 error: function(){//4.error 失败的回调方法
                 console.log("error");
                     $("#show").html("Error XMLHttpRequest");
                 }
             });
             
             
         
    });
                
    });
 
</script>
</body>
</html>